package J20241102_dichotomy;

/**
 * Created with IntelliJ IDEA.
 * Description: 浮点数二分
 * User: 王圆豪
 * Date: 2024-11-04
 * Time: 21:16
 */
public class Test_Dichotomy_Float {
    public static void main(String[] args) {
        int x = 456;
        double l = 0,r = x;
        while(r - l >= 0.00001){
            double mid = (r + l) / 2;
            if (Math.pow(mid, 2) >= x){
                r = mid;
            }else {
                l = mid;
            }
        }
        System.out.printf("%.2f", l);
    }
}
